//
//  MyEnshrineListCell.m
//  tryshopping.boss
//
//  Created by Mr.Lee on 2016/12/23.
//  Copyright © 2016年 Reabam. All rights reserved.
//

#import "MyEnshrineListCell.h"

@implementation MyEnshrineListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.selectBtn setImage:[UIImage imageNamed:@"meixuanzhong_normal"] forState:UIControlStateNormal];
    [self.selectBtn setImage:[UIImage imageNamed:@"xuanzhong_normal"] forState:UIControlStateSelected];
    [self.selectBtn addTarget:self action:@selector(selectedBtnClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

- (void)selectedBtnClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    sender.tag = self.index;
    if ([self.delegate respondsToSelector:@selector(selectedBtnClick:)]) {
        [self.delegate selectedBtnClick:sender];
    }
}

- (void)setModel:(MyEnshrineGoodsModel *)model{
    _model = model;
    
    // 图片
    [self.fullImageView sd_setImageWithURL:[NSURL URLWithString:model.imageUrlFull] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
    
    // 内容
    self.contentLabel.text = model.itemName;
    
    // 价格
    NSString *priceStr = [NSString stringWithFormat:@"¥%@", [Global floatConvertPercentile:[model.salePriceRange floatValue]]];
    self.priceLabel.text = priceStr;
    
    if (model.isSelected == YES) {
        [self.selectBtn setImage:[UIImage imageNamed:@"xuanzhong_normal"] forState:UIControlStateSelected];
        self.selectBtn.selected = YES;
    } else{
        self.selectBtn.selected = NO;
        [self.selectBtn setImage:[UIImage imageNamed:@"meixuanzhong_normal"] forState:UIControlStateNormal];
    }
  
}

@end
